<template>
    <div class="aside">
        <div class="toggle-button" @click="toggleCollapse">
            |||
        </div>

        <el-menu
            default-active="2"
            class="el-menu-vertical-demo"
            active-text-color="#fffff"
            :unique-opened = "true"
            :collapse="isCollapse"
             router>
            <el-sub-menu index="1">
                <template #title>
                    <el-icon class="el-input--medium"></el-icon>
                    <span>团队管理</span>
                </template>
                <el-menu-item-group>
                    <el-menu-item index="/team">团队列表</el-menu-item>
                </el-menu-item-group>
            </el-sub-menu>

            <el-sub-menu index="2">
                <template #title>
                    <el-icon><add-location /></el-icon>
                    <span>用户管理</span>
                </template>
                <el-menu-item-group>
                    <el-menu-item index="/userDetail">用户详情</el-menu-item>
                </el-menu-item-group>
            </el-sub-menu>

            <el-sub-menu index="3">
                <template #title>
                    <el-icon><add-location /></el-icon>
                    <span>文章管理</span>
                </template>
                <el-menu-item-group>
                    <el-menu-item index="/articleList">文章列表</el-menu-item>
                </el-menu-item-group>
            </el-sub-menu>

            <el-sub-menu index="4">
                <template #title>
                    <el-icon><add-location /></el-icon>
                    <span>资源管理</span>
                </template>
                <el-menu-item-group>
                    <el-menu-item index="/resourcesList">资源列表</el-menu-item>
                </el-menu-item-group>
            </el-sub-menu>

            <el-sub-menu index="5">
                <template #title>
                    <el-icon><add-location /></el-icon>
                    <span>数据统计</span>
                </template>
                <el-menu-item-group>
                    <el-menu-item index="/statistics">数据统计</el-menu-item>
                </el-menu-item-group>
            </el-sub-menu>
        </el-menu>
    </div>
</template>

<script>
export default{
    name:"vAside",
    props: ['getIsCollapse'],
    data() {
      return {
          menuList: [],
          isCollapse: false
      }
    },
    created() {
      // this.getMenuList()
    },
    watch:{
      isCollapse(){
          this.getIsCollapse(this.isCollapse)
      }
    },
    methods: {
        async getMenuList(){
            const {data : res} = await this.$http.get('menu')
            if (res.meta.status !==200) return this.$message.error(res.meta.msg)
            this.menuList = res.data
            console.log(res)
        },
        toggleCollapse(){
            this.isCollapse = !this.isCollapse
        }
    }
}

</script>

<style scoped>
.el-menu{
    border:none;
    background-color: rgba(255,255,255,0.1);
}
.el-sub-menu{
    background-color: rgba(255,255,255,0.1);
}

.aside{
    background-color: rgba(255,255,255,0.1);
}

.toggle-button{
    font-size: 10px;
    font-weight: bolder;
    line-height: 24px;
    color: #333333;
    text-align: center;
    letter-spacing: 0.2em;
    cursor: pointer;
}


</style>
